<template>
	<div id="">
		<el-table v-loading="loading" ref="multipleTable" :data="list" style="width: 100%" size="small"  border
			                row-key="id" :tree-props="{children: 'children'}" :indent="20">
			        <el-table-column label="名称" prop="name"></el-table-column>
			        <!-- <el-table-column label="ID" v-if="false"></el-table-column> -->
			        <el-table-column label="页面路径" prop="path"></el-table-column>
			        <el-table-column label="路由" prop="redirect_name"></el-table-column>
		<!-- 	        <el-table-column label="图标" align="center" width="150">
			          <template slot-scope="scope">
			            <svg-icon v-if="scope.row.icon"  class="svg-icon-M2class" :icon-class="scope.row.icon"  />
			          </template>
			        </el-table-column> -->
			        <!-- <el-table-column label="顺序" align="center" prop="seq" width="100"> -->
			        </el-table-column>
			        <el-table-column label="类型" prop="is_route" align="center" width="100">
			          <template slot-scope="scope">
			            <span v-if="scope.row.is_route==0">菜单</span>
			            <span v-if="scope.row.is_route==1">按钮</span>
			            <span v-if="scope.row.is_route==2">独立页</span>
			          </template>
			        </el-table-column>
			        <el-table-column label="操作" align="center" width="200">
			          <template slot-scope="scope">
			            <el-button type="success" size="mini" @click="editHandle(scope.row)" icon="el-icon-edit" >修改
			            </el-button>
			            <el-button type="danger" size="mini" @click="deleteHandle(scope.row)" icon="el-icon-delete">删除
			            </el-button>
			          </template>
			        </el-table-column>
		</el-table>	
	</div>
</template>

<script>
		import AuthApi from '@/api/auth.js'
		export default {
			created () {
				// 获取列表
				AuthApi.getAccessList().then((res)=>{
					// console.log(res)
					this.list = res.data.data
					this.loading=false
				})
			},
			data() {
				return {
					list: [],
					loading: true
				}
			},
			methods:{
				editHandle(row){
					// console.log(23)
					let params = [true,row.id]
					this.$emit('editClick',params)
					// this.$emit('changeEdit',true)
				},
				deleteHandle(row){
					let params = {'id':row.id}
					this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
					  confirmButtonText: '确定',
					  cancelButtonText: '取消',
					  type: 'warning'
					}).then(() => {
						AuthApi.del(params).then((res)=>{
							let type = res.data.code == 1?'success':'error';
							this.$message({
							  message: res.data.msg,
							  type: type
							});
							if(res.data.code == 1){
								this.$router.go(0)
							}
							// this.$router.go(0)
							
						})
					})		

				}
			}
		}
	
</script>

<style>
</style>
